//
//  TRBaseTool.m
//  UnaMicroBlog
//
//  Created by lanou3g on 15/10/24.
//  Copyright (c) 2015年 tanrong. All rights reserved.
//

#import "TRBaseTool.h"
#import "TRHTTPTool.h"
#import "MJExtension.h"

@implementation TRBaseTool
+(void)getWithUrl:(NSString *)url param:(id)param resultClass:(Class)resultClass success:(void (^)(id))success failure:(void (^)(NSError *))failure
{
    
    NSDictionary * params = [param keyValues];
    [TRHTTPTool get:url params:params success:^(id responseObj) {
        if (success) {
            id result = [resultClass objectWithKeyValues:responseObj];
            success(result);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];

}

+(void)postWithUrl:(NSString *)url param:(id)param resultClass:(Class)resultClass success:(void (^)(id))success failure:(void (^)(NSError *))failure
{
    NSDictionary * params = [param keyValues];
    [TRHTTPTool post:url params:params success:^(id responseObj) {
        if (success) {
            id result = [resultClass objectWithKeyValues:responseObj];
            success(result);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}


@end
